package com.bw.controller;

import com.bw.bean.Sugar;
import com.bw.bean.Sugar2;
import com.bw.bean.Sugar3;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list")
    public String t1(){
        List<Sugar2> list=sugarService.get1();
        List<String> list1=new ArrayList<>();
        list1.add("章节名称");
        list1.add("播放次数");
        list1.add("播放时长");
        list1.add("观看人数");
        list1.add("人均观看时长");
        return SugarUtil.getTablePlayData(list1,list);
    }

    @RequestMapping("/list2")
    public Map t2(){
        List<Sugar> list=sugarService.get2();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("/list3")
    public Map t3(){
        List<Sugar> list=sugarService.get3();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("/list4")
    public Map t4(){
        double list=sugarService.get4();
        Map map=new HashMap<>();
        map.put("status", 0);
        map.put( "data",list);
        return map;
    }

    @RequestMapping("/list5")
    public Map t5(){
        List<Sugar> list=sugarService.get5();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("/list6")
    public String t6(){
        List<Sugar3> list=sugarService.get6();
        List<String> list1=new ArrayList<>();
        list1.add("章节名称");
        list1.add("订单总额");
        list1.add("下单用户总数");
        list1.add("订单总数");
        return SugarUtil.getTablePlayData(list1,list);
    }

    @RequestMapping("/list7")
    public Map t7(){
        double list=sugarService.get7();
        Map map=new HashMap<>();
        map.put("status", 0);
        map.put( "data",list);
        return map;
    }

    @RequestMapping("/list8")
    public String t8(){
        List<Sugar> list=sugarService.get8();
        List<String> list1=new ArrayList<>();
        list1.add("课程名称");
        list1.add("订单金额");
        return SugarUtil.getTablePlayData(list1,list);
    }
}
